package com.example.demo.service.Impl;

import com.example.demo.dao.IGmmana;
import com.example.demo.model.Gmmana;
import com.example.demo.service.IGmmanaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

;

/**
 * @author Administrator 张少婷
 */

@Service
public class GmmanaServiceImpl implements IGmmanaService {

    @Autowired
    private IGmmana gmmanaMapper;
    @Override
    public int insertGmmana(Gmmana gmmana){
        int gmmanaValue=0;

        Gmmana gmmana1=new Gmmana();
        gmmana1.setLbid(gmmana.getLbid());
        List<Gmmana> getM=gmmanaMapper.getAllGmmana(gmmana1);
        if(getM.size()>0){
            gmmanaValue=-1;

        }else{
            gmmanaValue=gmmanaMapper.insertGmmana(gmmana);
        }

        return gmmanaValue;
    }

    @Override
    public List<Gmmana> getAllGmmana(Gmmana gmmana) {


        return gmmanaMapper.getAllGmmana(gmmana);
    }

    @Override
    public int updateGmmana(Gmmana gmmana) {
        int gmmanaValues=0;
        if(gmmana.getLbid()!=0){



            gmmanaValues=gmmanaMapper.updateGmmana(gmmana);
        }
        return gmmanaValues;
    }

    @Override
    public int deleteGmmana(Gmmana gmmana) {
        int gmmanaValues=0;
        if(gmmana.getLbid()!=0)
        {
            //主键是否与其他表有关联

            gmmanaValues=gmmanaMapper.deleteGmmana(gmmana);
        }
        return gmmanaValues;
    }

    @Override
    public Gmmana getGmmana(Gmmana gmmana) {
        Gmmana gmmana1=new Gmmana();
        if(gmmana.getLbid()!=0){
            gmmana1=gmmanaMapper.getGmmana(gmmana);
        }
        return gmmana1;
    }

}
